home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Power 1997 December
/
MACPOWER-1997-12.ISO.7z
/
MACPOWER-1997-12.ISO
/
AMUG
/
PROGRAMMING
/
Raven 1.2.sit
/
Raven 1.2
/
Source
/
Foundation
/
OS
/
ZNotify.h
< prev
next >
Wrap
Text File
|
1997-01-10
|
3KB
|
102 lines
/*
* File: ZNotify.h
* Summary: A wrapper around the Notification Manager.
* Written by: Jesse Jones
*
* Copyright ゥ 1996 Jesse Jones.
* For conditions of distribution and use, see copyright notice in ZTypes.h
*
* Change History (most recent first):
*
* <-> 1/09/96 JDJ Created
*/
#pragma once
#include <Notification.h>
#include <String>
#include <ZListener.h>
#include <ZStateBroadcaster.h>
// ===================================================================================
// class TNotify
// ===================================================================================
class TNotify : public MListener<SStateMessage> {
//-----------------------------------
// Initialization/Destruction
//
protected:
virtual ~TNotify();
// Protected to prevent allocation on the stack.
public:
TNotify(ResID iconID, ResID soundID = 0, bool useMark = true);
// Defaults to the "polite" notification: an icon blinking in
// the menu bar with the app's name marked. If iconID is 0 no
// icon is displayed. If iconID is greater than 0 an 'ics8' or
// 'ics4' resource is used. If soundID is -1 the system alert
// sound is played. If soundID is greater than 0 a 'snd '
// resource is played.
TNotify(const string& mesg, ResID iconID, ResID soundID = -1, bool useMark = true);
// The obnoxious notification: an alert is displayed in whatever
// app happens to be frontmost. This should be used sparingly.
TNotify(const string& mesg, ResID soundID = 0);
// Displays an alert without messing with the menu bar. This
// can be used when you want to display an alert in things like
// Drag Manager callbacks (note that you cannot use this in a
// VBL or Time Manager callback because the class doesn't use
// an interrupt safe version of operator new).
virtual void Post();
// To use a TNotify object first create it on the heap and then
// call Post. The object will be deleted automatically.
private:
TNotify(const TNotify& rhs);
TNotify& operator=(const TNotify& rhs);
//-----------------------------------
// New API
//
public:
virtual void HandleCallback();
protected:
virtual void OnCallback() {}
// This will be called after the sound has played or the user
// dismisses the alert. Note that Inside Mac says that this should
// not cause anything to be drawn or otherwise affect the interface.
//-----------------------------------
// Inherited API
//
protected:
virtual void OnBroadcast(const SStateMessage& mesg);
// Deletes the object if message is kResumingApp.
//-----------------------------------
// Internal API
//
private:
static pascal void DoCallback(NMRec* record);
void Init(const string& mesg, ResID iconID, ResID soundID, bool useMark);
//-----------------------------------
// Member data
//
public:
NMRec mRecord;
unsigned char* mText;
bool mCalledFromForeground;
bool mInstalled;
};